<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script>
			/*在内置的数组对象扩展一个数组去重的方法*/
			Array.prototype.unique1 = function(){
			var res = [this[0]];
			for(var i = 1; i < this.length; i++){
				var repeat = false;
				for(var j = 0; j < res.length; j++){
					if(this[i] == res[j]){
						repeat = true;
						break;
					}
				}
				if(!repeat){
					res.push(this[i]);
				}
			}
			return res;
		}
		var arr = [1, 'a', 'a', 'b', 'd', 'e', 'e', 1, 0]
		console.log("旧数组：",arr);
		console.log("新数组：",arr.unique1());
		</script>
		<script>
			//判断每一个数是否在数组中
			var numArr = [1,2,3,4,5,6,7];
			var num = 8;
			var  flag = numArr.every(function(val,index){
				return val != num;
			})
			if(flag){
				numArr.push(num);
			}
			console.log(numArr);
		</script>
	</body>
</html>
